package com.just.springmvc4.service;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult;

@Service
public class PushService {
    private DeferredResult<String> deferredResult;
    public DeferredResult<String> getAsyncUpdate(){
        deferredResult=new DeferredResult<String>();
        return deferredResult;
    }
    @Scheduled(fixedDelay = 3000)
    public void refresh(){
        if(deferredResult!=null){
            deferredResult.setResult("当前时间戳:"+System.currentTimeMillis());
        }
    }

}
